package com.es.www.kyl.controller.web;

import com.es.www.kyl.bean.R;
import com.es.www.kyl.bean.req.web.UserReq;
import com.es.www.kyl.bean.req.web.UserUpdateReq;
import com.es.www.kyl.bean.res.web.UserVO;
import com.es.www.kyl.service.UserService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Estranger
 * @date 2025/7/31
 * description
 */
@Api(tags = "用户模块")
@RequiredArgsConstructor
@RestController
@RequestMapping("/web/user")
public class UserController {

	private final UserService userService;

	/**
	 * 用户列表
	 */
	@ApiOperation("用户列表")
	@PostMapping("/pageQueryUserList")
	public R<PageInfo<UserVO>> pageQueryUserList(@RequestBody UserReq userReq) {
		return R.successResponse(userService.pageQueryUserList(userReq));
	}

	@ApiOperation("更新用户")
	@PostMapping("/updateUser")
	public R<Void> updateUser(@RequestBody UserUpdateReq userUpdateReq) {
		userService.updateUser(userUpdateReq);
		return R.successCommonResponse();
	}

	@ApiOperation("获取用户信息")
	@PostMapping("/getUserInfo")
	public R<UserVO> getUserInfo () {
		return R.successResponse(userService.getUserInfo());
	}

}
